<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2022-12-18 17:58:47
 * @Last Modified time: 2023-02-20 14:00:07
 */
namespace app\common\services\store;

use app\common\dao\store\GoodsUnitDao;

use frank\base\BaseService;
use frank\exception\CommonException;
use frank\utils\helper\ArrayHelper;

/**
 * Class GoodsUnitService
 */
class GoodsUnitService extends BaseService
{

    /**
     * GoodsUnitService constructor.
     * @param GoodsUnitDao $dao
     */
    public function __construct(GoodsUnitDao $dao)
    {
        $this->dao = $dao;
    }

    public function getGoodsUnitDetail($filter)
    {
        $detail = $this->dao->detail($filter);
        if (!$detail) {
            throw new CommonException('数据不存在');
        }
        return $detail->toArray();
    }

    /**
     * 获取列表
     */
    public function getGoodsUnitList(array $where)
    {
        [$page, $limit] = $this->getPageValue();
        $list = $this->dao->getGoodsUnitList($where, $page, $limit);
        return $list;
    }

    /**
     * 获取列表
     */
    public function getGoodsUnitSelect(array $where = [])
    {
        $select = $this->dao->getGoodsUnitSelect($where);
        return $select;
    }
}
